<script setup lang="ts">
import { ref } from 'vue';

const isShow = ref(false)
const toggle = () => {
  isShow.value = !isShow.value
}
</script>


<template>
  <button @click="toggle">切换显示/隐藏</button>
  <hr>
  <div v-show="isShow" class="box">我是v-show控制的盒子</div>
  <div v-if="isShow" class="box">我是v-if控制的盒子</div>
</template>

<style>
.box {
  width: 100px;
  height: 100px;
  background-color: red;
  margin-bottom: 20px;
}
</style>
